package com.app.base.service.core.employees.controller;


import com.app.base.service.core.employees.entity.EmpType;
import com.app.base.service.core.employees.service.EmpTypeService;
import com.app.base.utlis.auth.JwtHelper;
import com.app.base.utlis.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 *  前端控制器
 * @author yuhag
 * @since 2022-05-11
 */
@RestController
@RequestMapping("/empTypeController")
@Api(tags = "员工管理")
public class EmpTypeController {

    @Resource
    private EmpTypeService typeService;

    @PostMapping("saveOrUpdateEmpType")
    @ApiOperation("添加或修改员工工作类型")
    public Result saveOrUpdateEmpType(HttpServletRequest request, @RequestBody EmpType type){
        String userId = JwtHelper.getMemberIdByJwtToken(request);
        return typeService.saveOrUpdateEmpType(userId,type);
    }

    @GetMapping("pageEmpList")
    @ApiOperation("分页显示员工工作类型基础基础数据")
    public Result pageEmpList(@RequestParam(value = "current" ,defaultValue = "1") Long current,
                              @RequestParam(value = "pageSize",defaultValue = "10")Long pageSize){
        return typeService.pageEmpList(current,pageSize);
    }

    @GetMapping("typeList")
    @ApiOperation("显示员工工作类型基础基础数据列表")
    public Result empList(HttpServletRequest request){
        return typeService.empList(request);
    }


}

